{{ function_comment }}
int {{ function_name }}(exi_bitstream_t* stream, struct {{ struct_type }}* {{ parameter_name }})
{
{{ indent }}uint32_t eventCode;
{{ indent }}int error = exi_header_read_and_check(stream);

{{ indent }}if (error == EXI_ERROR__NO_ERROR)
{{ indent }}{
{{ indent * 2 }}init_{{ struct_type }}({{ parameter_name }});

{{ indent * 2 }}error = exi_basetypes_decoder_nbit_uint(stream, {{ bits_to_encode }}, &eventCode);
{{ indent * 2 }}if (error == EXI_ERROR__NO_ERROR)
{{ indent * 2 }}{
{{ indent * 3     }}switch (eventCode)
{{ indent * 3     }}{
{{ indent * 3     }}case 0:
{{ indent * 3     }}case {{ parameter_index }}:
{{ indent * 4         }}error = {{ function }}(stream, &{{ parameter }});
{{ indent * 4         }}break;
{{ indent * 3     }}default:
{{ indent * 4         }}error = EXI_ERROR__UNSUPPORTED_SUB_EVENT;
{{ indent * 4         }}break;
{{ indent * 3     }}}
{{ indent * 2 }}}
{{ indent }}}

{{ indent }}return error;
}
